package org.jdemo.orm.mybatis.support;

import java.io.Serializable;
import java.util.List;

/**
 * Paged
 *
 * @author longlin(longlin@cyou-inc.com)
 * @date 202014/4/15
 * @since V1.0
 */
public class Paged<T> implements Serializable {
    private static final long serialVersionUID = 5246627934455392469L;

    /**
     * 每页默认10条数据
     */
    protected int pageSize = 10;
    /**
     * 当前页
     */
    protected int pageNo = 1;
    /**
     * 总页数
     */
    protected int totalPage = 0;
    /**
     * 总数据数
     */
    protected int totalSize = 0;
    /**
     * 数据
     */
    private List<T> list;

    public Paged(int totalSize, int pageNo, int pageSize, List<T> list) {
        this.totalSize = totalSize;
        this.pageNo = pageNo;
        this.pageSize = pageSize;
        this.list = list;
        this.totalPage = (totalSize % pageSize == 0) ? (totalSize / pageSize) : (totalSize / pageSize + 1);
    }

    public int getPageSize() {
        return pageSize;
    }

    public int getPageNo() {
        return pageNo;
    }

    public int getTotalPage() {
        return totalPage;
    }

    public int getTotalSize() {
        return totalSize;
    }

    public List<T> getList() {
        return list;
    }
}
